package com.party.core.service.photo.impl;

import com.google.common.base.Strings;
import com.party.common.paging.Page;
import com.party.core.dao.read.photo.PhotoProjectReadDao;
import com.party.core.dao.write.photo.PhotoProjectWriteDao;
import com.party.core.model.BaseModel;
import com.party.core.model.photo.PhotoProject;
import com.party.core.service.photo.IPhotoProjectService;
import com.sun.istack.NotNull;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * Created by Administrator on 2018/5/29/029.
 */
@Service
public class PhotoProjectService implements IPhotoProjectService{
    @Autowired
    private  PhotoProjectReadDao photoProjectReadDao;
    @Autowired
    private PhotoProjectWriteDao photoProjectWriteDao;

    public String insert(PhotoProject photoProject) {
        BaseModel.preInsert(photoProject);
        boolean result = photoProjectWriteDao.insert(photoProject);
        if(result){
            return  photoProject.getId();
        }
        return photoProject.getId();
    }

    public boolean update(PhotoProject photoProject) {
        return photoProjectWriteDao.update(photoProject);
    }

    public boolean deleteLogic(@NotNull String id) {
        if (Strings.isNullOrEmpty(id)) {
            return false;
        }
        return photoProjectWriteDao.deleteLogic(id);
    }

    public boolean delete(@NotNull String id) {
        if (Strings.isNullOrEmpty(id)) {
            return false;
        }
        return photoProjectWriteDao.delete(id);
    }

    public boolean batchDeleteLogic(@NotNull Set<String> ids) {
        if (CollectionUtils.isEmpty(ids)) {
            return false;
        }
        return photoProjectWriteDao.batchDeleteLogic(ids);
    }

    public boolean batchDelete(@NotNull Set<String> ids) {
        if (CollectionUtils.isEmpty(ids)) {
            return false;
        }
        return photoProjectWriteDao.batchDelete(ids);
    }

    public PhotoProject get(String id) {
        return photoProjectReadDao.get(id);
    }

    public List<PhotoProject> listPage(PhotoProject photoProject, Page page) {
        return photoProjectReadDao.listPage(photoProject,page);
    }

    public List<PhotoProject> list(PhotoProject photoProject) {
        return photoProjectReadDao.listPage(photoProject,null);
    }

    public List<PhotoProject> batchList(@NotNull Set<String> ids, PhotoProject photoProject, Page page) {
        return null;
    }

    @Override
    public List<PhotoProject> webListPage(Map<String, Object> params, Page page) {

        return photoProjectReadDao.webListPage(params,page);
    }

    @Override
    public Map<String, Object> countAnalyzeByDate(String startDate, String endDate, Map<String, Object> params) {
        return photoProjectReadDao.countAnalyzeByDate(startDate, endDate, params);
    }

    @Override
    public List<PhotoProject> batchByMember(Set<String> memberIds, Page page) {
        return photoProjectReadDao.batchByMember(memberIds, page);
    }

    @Override
    public List<String> getXzgsPhotoList(String title, String xzgsMemberId) {
        return photoProjectReadDao.getXzgsPhotoList(title, xzgsMemberId);
    }

    @Override
    public void updateMember(String id, String memberId) {
        photoProjectWriteDao.updateMember(id, memberId);
    }
}
